<?php
	date_default_timezone_set('Europe/London');
	// Dinh nghia duong dan den thu vien cua Zend
	set_include_path('./library/'
			. PATH_SEPARATOR . './application/models'. PATH_SEPARATOR . './application/');
	
	// Goi class Zend_Load
	include "./library/Zend/Loader.php";	
	//Goi class Controller
	
	Zend_Loader::loadClass('Zend_Http_UserAgent');
    $userAgent = new Zend_Http_UserAgent();    
	$device    = $userAgent->getDevice();
	$browserType = $userAgent->getBrowserType();
	
	Zend_Loader::loadClass('Zend_Controller_Front');	
	Zend_Loader::loadClass('Zend_View');	
	Zend_Loader::loadClass('Zend_Config_Ini');		
	Zend_Loader::loadClass('Zend_Registry');
	Zend_Loader::loadClass('Zend_Layout');	
	Zend_Loader::loadClass('Zend_Db');	
	Zend_Loader::loadClass('Efy_Db_Connection');	
	Zend_Loader::loadClass('Efy_Library');		
	Zend_Loader::loadClass('Efy_Xml');
	Zend_Loader::loadClass('Efy_Init_Session');	
	Zend_Loader::loadClass('Efy_Init_Config');
	Zend_Loader::loadClass('Efy_Function_DocFunctions'); //Goi lop tao cac phuong thuc dung chung
	Zend_Loader::loadClass('Efy_Publib_Browser'); 

	/*Zend_Loader::loadClass('Efy_Publib_Browser'); */
	/*Zend_Loader::loadClass('Efy_phpDocx');*/
	@session_start();
	//Khai bao bien toan cuc 
	$conDirApp = new Zend_Config_Ini('./config/config.ini','dirApp');
	$registry = Zend_Registry::getInstance();
	$registry->set('conDirApp', $conDirApp);	
	$registry->set('browserType',$browserType);
	//Dinh nghia hang so dung chung 
	$ConstPublic = new Zend_Config_Ini('./config/config.ini','ConstPublic');
	$registry = Zend_Registry::getInstance();
	$registry->set('ConstPublic', $ConstPublic);	
	
	//Ket noi CSDL SQL theo kieu ADODB
	$connectSQL = new Zend_Config_Ini('./config/config.ini','dbmssql');
	$registry = Zend_Registry::getInstance();
	$registry->set('connectSQL', $connectSQL);
	$connAdo = Efy_Db_Connection::connectADO($connectSQL->db->adapter,$connectSQL->db->config->toArray());
	
	$url = Efy_Function_DocFunctions::curPageURL();
	//echo $_SERVER["REQUEST_URI"];           
    // Goi ham kiem tra user login
    if($_SERVER["REQUEST_URI"]<>'/qlvbdh/schedule/tivi/index/'){
    	Efy_Function_DocFunctions::CheckLogin($url);
    }
	
	// setup controller
	$frontController = Zend_Controller_Front::getInstance();	
	$frontController->addControllerDirectory('./application/controllers');
	$frontController->addControllerDirectory('./application/listxml/controllers', 'listxml');
	$frontController->addControllerDirectory('./application/logout/controllers','logout');
	$frontController->addControllerDirectory('./application/login/controllers','login');
	$frontController->addControllerDirectory('./application/web/controllers','web');
	$frontController->addControllerDirectory('./application/ajax/controllers', 'ajax');
	$frontController->throwExceptions(true);
	$frontController->setDefaultModule('login');
	$frontController->dispatch();
?>